'\" t
.\" Copyright (c) 2001 Martin Schulze <joey@infodrom.org>
.\"
.\" SPDX-License-Identifier: GPL-2.0-or-later
.\"
.TH dir_colors 5 2024-06-16 "Linux man-pages 6.9.1"
.SH NAME
dir_colors \- configuration file for dircolors(1)
.SH DESCRIPTION
The program
.BR ls (1)
uses the environment variable
.B LS_COLORS
to determine the colors in which the filenames are to be displayed.
This environment variable is usually set by a command like
.P
.RS
eval \`dircolors some_path/dir_colors\`
.RE
.P
found in a system default shell initialization file, like
.I /etc/profile
or
.IR /etc/csh.cshrc .
(See also
.BR dircolors (1).)
Usually, the file used here is
.I /etc/DIR_COLORS
and can be overridden by a
.I .dir_colors
file in one's home directory.
.P
This configuration file consists of several statements, one per line.
Anything right of a hash mark (#) is treated as a comment, if the
hash mark is at the beginning of a line or is preceded by at least one
whitespace.
Blank lines are ignored.
.P
The
.I global
section of the file consists of any statement before the first
.B TERM
statement.
Any statement in the global section of the file is
considered valid for all terminal types.
Following the global section
is one or more
.I terminal-specific
sections, preceded by one or more
.B TERM
statements which specify the terminal types (as given by the
.B TERM
environment variable) the following declarations apply to.
It is always possible to override a global declaration by a subsequent
terminal-specific one.
.P
The following statements are recognized; case is insignificant:
.TP
.B TERM \fIterminal-type\fR
Starts a terminal-specific section and specifies which terminal it
applies to.
Multiple
.B TERM
statements can be used to create a section which applies for several
terminal types.
.TP
.B COLOR yes|all|no|none|tty
(Slackware only; ignored by GNU
.BR dircolors (1).)
Specifies that colorization should always be enabled (\fIyes\fR or
\fIall\fR), never enabled (\fIno\fR or \fInone\fR), or enabled only if
the output is a terminal (\fItty\fR).
The default is \fIno\fR.
.TP
.B EIGHTBIT yes|no
(Slackware only; ignored by GNU
.BR dircolors (1).)
Specifies that eight-bit ISO/IEC\~8859 characters should be enabled by
default.
For compatibility reasons, this can also be specified as 1 for
\fIyes\fR or 0 for \fIno\fR.
The default is \fIno\fR.
.TP
.B OPTIONS \fIoptions\fR
(Slackware only; ignored by GNU
.BR dircolors (1).)
Adds command-line options to the default
.B ls
command line.
The options can be any valid
.B ls
command-line options, and should include the leading minus sign.
Note that
.B dircolors
does not verify the validity of these options.
.TP
.B NORMAL \fIcolor-sequence\fR
Specifies the color used for normal (nonfilename) text.
.IP
Synonym:
.BR NORM .
.TP
.B FILE \fIcolor-sequence\fR
Specifies the color used for a regular file.
.TP
.B DIR \fIcolor-sequence\fR
Specifies the color used for directories.
.TP
.B LINK \fIcolor-sequence\fR
Specifies the color used for a symbolic link.
.IP
Synonyms:
.BR LNK ,
.BR SYMLINK .
.TP
.B ORPHAN \fIcolor-sequence\fR
Specifies the color used for an orphaned symbolic link (one which
points to a nonexistent file).
If this is unspecified,
.B ls
will use the
.B LINK
color instead.
.TP
.B MISSING \fIcolor-sequence\fR
Specifies the color used for a missing file (a nonexistent file which
nevertheless has a symbolic link pointing to it).
If this is unspecified,
.B ls
will use the
.B FILE
color instead.
.TP
.B FIFO \fIcolor-sequence\fR
Specifies the color used for a FIFO (named pipe).
.IP
Synonym:
.BR PIPE .
.TP
.B SOCK \fIcolor-sequence\fR
Specifies the color used for a socket.
.TP
.B DOOR \fIcolor-sequence\fR
(Supported since fileutils 4.1)
Specifies the color used for a door (Solaris 2.5 and later).
.TP
.B BLK \fIcolor-sequence\fR
Specifies the color used for a block device special file.
.IP
Synonym:
.BR BLOCK .
.TP
.B CHR \fIcolor-sequence\fR
Specifies the color used for a character device special file.
.IP
Synonym:
.BR CHAR .
.TP
.B EXEC \fIcolor-sequence\fR
Specifies the color used for a file with the executable attribute set.
.TP
.B SUID \fIcolor-sequence\fR
Specifies the color used for a file with the set-user-ID attribute set.
.IP
Synonym:
.BR SETUID .
.TP
.B SGID \fIcolor-sequence\fR
Specifies the color used for a file with the set-group-ID attribute set.
.IP
Synonym:
.BR SETGID .
.TP
.B STICKY \fIcolor-sequence\fR
Specifies the color used for a directory with the sticky attribute set.
.TP
.B STICKY_OTHER_WRITABLE \fIcolor-sequence\fR
Specifies the color used for
an other-writable directory with the executable attribute set.
.IP
Synonym:
.BR OWT .
.TP
.B OTHER_WRITABLE \fIcolor-sequence\fR
Specifies the color used for
an other-writable directory without the executable attribute set.
.IP
Synonym:
.BR OWR .
.TP
.B LEFTCODE \fIcolor-sequence\fR
Specifies the
.I "left code"
for non-ISO/IEC\~6429 terminals (see below).
.IP
Synonym:
.BR LEFT .
.TP
.B RIGHTCODE \fIcolor-sequence\fR
Specifies the
.I "right code"
for non-ISO/IEC\~6429 terminals (see below).
.IP
Synonym:
.BR RIGHT .
.TP
.B ENDCODE \fIcolor-sequence\fR
Specifies the
.I "end code"
for non-ISO/IEC\~6429 terminals (see below).
.IP
Synonym:
.BR END .
.TP
.BI * "extension color-sequence"
Specifies the color used for any file that ends in \fIextension\fR.
.TP
.BI . "extension color-sequence"
Same as \fB*\fR.\fIextension\fR.
Specifies the color used for any file that
ends in .\fIextension\fR.
Note that the period is included in the
extension, which makes it impossible to specify an extension not
starting with a period, such as
.B \[ti]
for
.B emacs
backup files.
This form should be considered obsolete.
.SS ISO/IEC\~6429 (ANSI) color sequences
Most color-capable ASCII terminals today use
ISO/IEC\~6429 (ANSI) color sequences,
and many common terminals without color capability, including
.B xterm
and the widely used and cloned DEC VT100, will recognize ISO/IEC\~6429 color
codes and harmlessly eliminate them from the output or emulate them.
.B ls
uses ISO/IEC\~6429 codes by default, assuming colorization is enabled.
.P
ISO/IEC\~6429 color sequences are composed of sequences of numbers
separated by semicolons.
The most common codes are:
.RS
.TS
l l.
 0	to restore default color
 1	for brighter colors
 4	for underlined text
 5	for flashing text
30	for black foreground
31	for red foreground
32	for green foreground
33	for yellow (or brown) foreground
34	for blue foreground
35	for purple foreground
36	for cyan foreground
37	for white (or gray) foreground
40	for black background
41	for red background
42	for green background
43	for yellow (or brown) background
44	for blue background
45	for purple background
46	for cyan background
47	for white (or gray) background
.TE
.RE
.P
Not all commands will work on all systems or display devices.
.P
.B ls
uses the following defaults:
.TS
lb l l.
NORMAL	0       	Normal (nonfilename) text
FILE	0       	Regular file
DIR	32      	Directory
LINK	36      	Symbolic link
ORPHAN	undefined	Orphaned symbolic link
MISSING	undefined	Missing file
FIFO	31      	Named pipe (FIFO)
SOCK	33      	Socket
BLK	44;37   	Block device
CHR	44;37   	Character device
EXEC	35      	Executable file
.TE
.P
A few terminal programs do not recognize the default
properly.
If all text gets colorized after you do a directory
listing, change the
.B NORMAL
and
.B FILE
codes to the numerical codes for your normal foreground and background
colors.
.SS Other terminal types (advanced configuration)
If you have a color-capable (or otherwise highlighting) terminal (or
printer!) which uses a different set of codes, you can still generate
a suitable setup.
To do so, you will have to use the
.BR LEFTCODE ,
.BR RIGHTCODE ,
and
.B ENDCODE
definitions.
.P
When writing out a filename,
.B ls
generates the following output sequence:
.B LEFTCODE
.I typecode
.B RIGHTCODE
.I filename
.BR ENDCODE ,
where the
.I typecode
is the color sequence that depends on the type or name of file.
If the
.B ENDCODE
is undefined, the sequence
.B "LEFTCODE NORMAL RIGHTCODE"
will be used instead.
The purpose of the left- and rightcodes is
merely to reduce the amount of typing necessary (and to hide ugly
escape codes away from the user).
If they are not appropriate for
your terminal, you can eliminate them by specifying the respective
keyword on a line by itself.
.P
.B NOTE:
If the
.B ENDCODE
is defined in the global section of the setup file, it
.I cannot
be undefined in a terminal-specific section of the file.
This means any
.B NORMAL
definition will have no effect.
A different
.B ENDCODE
can, however, be specified, which would have the same effect.
.SS Escape sequences
To specify control- or blank characters in the color sequences or
filename extensions, either C-style \[rs]-escaped notation or
.BR stty \-style
\[ha]-notation can be used.
The C-style notation
includes the following characters:
.RS
.TS
lb l.
\[rs]a	Bell (ASCII 7)
\[rs]b	Backspace (ASCII 8)
\[rs]e	Escape (ASCII 27)
\[rs]f	Form feed (ASCII 12)
\[rs]n	Newline (ASCII 10)
\[rs]r	Carriage Return (ASCII 13)
\[rs]t	Tab (ASCII 9)
\[rs]v	Vertical Tab (ASCII 11)
\[rs]?	Delete (ASCII 127)
\[rs]\fInnn	Any character (octal notation)
\[rs]x\fInnn	Any character (hexadecimal notation)
\[rs]_	Space
\[rs]\[rs]	Backslash (\[rs])
\[rs]\[ha]	Caret (\[ha])
\[rs]#	Hash mark (#)
.TE
.RE
.P
Note that escapes are necessary to enter a space, backslash,
caret, or any control character anywhere in the string, as well as a
hash mark as the first character.
.SH FILES
.TP
.I /etc/DIR_COLORS
System-wide configuration file.
.TP
.I \[ti]/.dir_colors
Per-user configuration file.
.P
This page describes the
.B dir_colors
file format as used in the fileutils-4.1 package;
other versions may differ slightly.
.SH NOTES
The default
.B LEFTCODE
and
.B RIGHTCODE
definitions, which are used by ISO/IEC\~6429 terminals are:
.RS
.TS
lb l.
LEFTCODE	\[rs]e[
RIGHTCODE	m
.TE
.RE
.P
The default
.B ENDCODE
is undefined.
.SH SEE ALSO
.BR dircolors (1),
.BR ls (1),
.BR stty (1),
.BR xterm (1)
